package pers.linkong.asr.web;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import pers.linkong.asr.domain.CourseBean;

@Controller
@RequestMapping("/main")
public class MainController {
	
	@RequestMapping("/home")
	public String home(HttpSession session) {
		Object tid = session.getAttribute("loginTid");
		if(tid==null || tid=="" || tid == "null"){
			return "Login";
		}
		return "Home";
	}
	
	@RequestMapping("/record")
	public String record(HttpSession session) {
		Object tid = session.getAttribute("loginTid");
		if(tid==null || tid=="" || tid == "null"){
			return "Login";
		}
		return "RecordList";
	}
	
	@RequestMapping("/student")
	public String student(HttpSession session) {
		Object tid = session.getAttribute("loginTid");
		if(tid==null || tid=="" || tid == "null"){
			return "Login";
		}
		return "StuList";
	}
	
	@RequestMapping("/teacher")
	public String teacher(HttpSession session) {
		Object tid = session.getAttribute("loginTid");
		if(tid==null || tid=="" || tid == "null"){
			return "Login";
		}
		return "Teacher";
	}
	
	@RequestMapping("/schedule")
	public String schedule(HttpSession session) {
		Object tid = session.getAttribute("loginTid");
		if(tid==null || tid=="" || tid == "null"){
			return "Login";
		}
		return "Schedule";
	}
	
	@RequestMapping("/visual")
	public String visual(HttpSession session) {
		Object tid = session.getAttribute("loginTid");
		if(tid==null || tid=="" || tid == "null"){
			return "Login";
		}
		return "Visual";
	}
	
	@RequestMapping("/course")
	public String course(HttpSession session) {
		Object tid = session.getAttribute("loginTid");
		if(tid==null || tid=="" || tid == "null"){
			return "Login";
		}
		return "CourseList";
	}
	
	@RequestMapping("/courseSub")
	public String courseSub(CourseBean course, HttpSession session) {
		session.setAttribute("courseId",course.getCid());
		session.setAttribute("courseName",course.getCname());
		session.setAttribute("courseWeek",course.getWeeksum());
		return "CourseSub";
	}
}
